<template>
  <div>
    <!-- 轮播图 -->
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item v-for="item in lunboList" :key="item.id">
        <img :src="item.img">
      </van-swipe-item>
    </van-swipe>
    <!-- 宫格系统 -->
    <van-grid :column-num="3" :border="false">
      <van-grid-item to="/newslist">
        <img src="../assets/images/menu1.png" alt="">
        <p>新闻资讯</p>
      </van-grid-item>
      <van-grid-item to="/photo/list">
        <img src="../assets/images/menu2.png" alt="">
        <p>图片分享</p>
      </van-grid-item>
      <van-grid-item to="/goods/list">
        <img src="../assets/images/menu3.png" alt="">
        <p>商品购买</p>
      </van-grid-item>
      <van-grid-item>
        <img src="../assets/images/menu4.png" alt="">
        <p>留言反馈</p>
      </van-grid-item>
      <van-grid-item>
        <img src="../assets/images/menu5.png" alt="">
        <p>视频专区</p>
      </van-grid-item>
      <van-grid-item>
        <img src="../assets/images/menu6.png" alt="">
        <p>联系我们</p>
      </van-grid-item>
    </van-grid>
  </div>
</template>

<script>
export default {
  data() {
    return {
      //用来保存轮播图数据
      lunboList: []
    };
  },
  methods: {
    async getLunbo() {
      //发送请求得到轮播图数据，并且将轮播图进行渲染
      const { data: res } = await this.$http.get("/api/getlunbo");

      //将获取的轮播图数据保存到lunboList里面
      this.lunboList = res.message;
    }
  },
  created() {
    this.getLunbo();
  }
};
</script>


<style lang="less" scoped>
.my-swipe .van-swipe-item {
  height: 170px;
  img {
    width: 100%;
    height: 100%;
  }
}

.van-grid-item{
  width:33.333%;
  border:none;
  img{
    width: 60px;
  }
}
</style>
